package com.yrc.exception;

import com.yrc.utils.R;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

/**
 * @Author: Yrc
 * @create: 2020/12/14 0:12
 */
@RestControllerAdvice
public class CustomExceptionHandler {

    //上传文件超过500k，捕获异常：MaxUploadSizeExceededException
    @ExceptionHandler(MaxUploadSizeExceededException.class)
    public R handlerMaxUploadFile(MaxUploadSizeExceededException ex) {
        return R.errorMsg("文件上传大小不能超过500k，请压缩图片或降低图片质量再上传");
    }
}
